{{assign var="title" value="添加理财产品"}}
{{include file="admin/intop.html"}}
<style>
        .lr{width:120px;}
        td.lf input{float:left;}
        td.lf select{float:left;}
        td.lf textarea{float:left;}
        .ico-succ{display: none;}
        span.float_left{float: left;}
</style>
<script src="res/js/jquery/jquery-migrate-1.1.1.js" type="text/javascript"></script>
<script src="res/js/base.js" type="text/javascript"></script>
<script type="text/javascript" src="res/js/formvalidator/formValidator-4.1.3.js"></script>
<script type="text/javascript" src="res/js/formvalidator/formValidatorRegex.js" ></script>
<script type="text/javascript" src="res/js/lhgcalendar/lhgcalendar.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $('#repay_start_time').calendar();
    $('#bad_time').calendar();
});
</script>
<script type="text/javascript">
function list(){    
    window.location.href = "admin.php?ctl=deal&t={{if $dealItem.TYPE == 1 || $smarty.request.t == 'j'}}j{{else}}l{{/if}}";
}
$(document).ready(function(){
    $.formValidator.initConfig({theme:"126",formID:"form1",mode:'AutoTip',onError:function(msg){alert(msg)},inIframe:true});
//    $("#username").formValidator({onShow:"请输入手机号码",onFocus:"手机号码必须为11位,请确认",onCorrect:"该手机号码可以注册"}).inputValidator({min:11,max:11,onError:"手机号码必须为11位,请确认"}).regexValidator({regExp:"mobile",dataType:"enum",onError:"手机的格式不正确"})
//    .ajaxValidator({
//        dataType : "json",
//        async : true,
//        url : "index.php?{{$TIN_CTL}}=user&{{$TIN_ACT}}=chk&id={{$user.ID}}",
//        success : function(data){
//            if(data.code=='success') {
//                return true;
//            }else{
//                return data.msg;
//            }
//        },
//        buttons: $("#submit"),
//        error: function(jqXHR, textStatus, errorThrown){alert("服务器没有返回数据，请重试"+errorThrown);},
//        onError : "该手机号码不可用，请更换手机号码",
//        onWait : "正在校验，请稍候..."
//    });
    //$("#email").formValidator({onShowFixText:"6~18个字符，包括字母、数字、下划线，以字母开头，字母或数字结尾",onShow:"请输入邮箱",onFocus:"邮箱6-100个字符,输入正确了才能离开焦点",onCorrect:"恭喜你,你输对了",defaultValue:"{{if $user.userinfo.EMAIL}}{{$user.userinfo.EMAIL}}{{else}}@{{/if}}"}).inputValidator({min:6,max:100,onError:"你输入的邮箱长度非法,请确认"}).regexValidator({regExp:"^([\\w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([\\w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$",onError:"你输入的邮箱格式不正确"});
    //$("#idcard").formValidator({onShow:"请输入15或18位的身份证",onfocus:"输入15或18位的身份证",onCorrect:"输入正确"}).regexValidator({regExp:"idcard",dataType:"enum",onError:"你输入的身份证格式不正确"});;
    
    $("#finance").formValidator({onShow:"至少1个长度",onCorrect:""}).inputValidator({min:1,onError: "请选择融资方!"}).defaultPassed();
    
    var input_correct = "输入正确";
    var temp_n = "请输入理财名称";
    $("#title").formValidator({onShow:temp_n,onfocus:temp_n,onCorrect:input_correct}).inputValidator({min:2,onError:temp_n}).regexValidator({regExp:"notempty",dataType:"enum",onError:temp_n});
    var temp_n = "请输入融资总额";
    $("#price").formValidator({onShow:temp_n,onfocus:temp_n,onCorrect:input_correct}).inputValidator({min:2,onError:temp_n}).regexValidator({regExp:"notempty",dataType:"enum",onError:temp_n});
    var temp_n = "请输入单笔最大投资额";
    $("#max_load").formValidator({onShow:temp_n,onfocus:temp_n,onCorrect:input_correct}).inputValidator({min:2,onError:temp_n}).regexValidator({regExp:"notempty",dataType:"enum",onError:temp_n});
    var temp_n = "请输入批准总额";
    $("#price_allow").formValidator({onShow:temp_n,onfocus:temp_n,onCorrect:input_correct}).inputValidator({min:2,onError:temp_n}).regexValidator({regExp:"notempty",dataType:"enum",onError:temp_n});
    var temp_n = "请输入年化收益率";
    $("#rate").formValidator({onShow:temp_n,onfocus:temp_n,onCorrect:input_correct}).inputValidator({min:1,onError:temp_n}).regexValidator({regExp:"notempty",dataType:"enum",onError:temp_n});
    var temp_n = "请输入开始还款日期";
    $("#repay_start_time").formValidator({onShow:temp_n,onfocus:temp_n,onCorrect:input_correct}).inputValidator({min:2,onError:temp_n}).regexValidator({regExp:"notempty",dataType:"enum",onError:temp_n});
    var temp_n = "请输入流标时间";
    $("#bad_time").formValidator({onShow:temp_n,onfocus:temp_n,onCorrect:input_correct}).inputValidator({min:2,onError:temp_n}).regexValidator({regExp:"notempty",dataType:"enum",onError:temp_n});
    
    $("#repay_time").formValidator({onShow:"至少1个长度",onCorrect:""}).inputValidator({min:1,onError: "请选择借款期限!"}).defaultPassed();
    $("#type_borrow").formValidator({onShow:"至少1个长度",onCorrect:""}).inputValidator({min:1,onError: "请选择借款方式!"}).defaultPassed();
    $("#type_repay").formValidator({onShow:"至少1个长度",onCorrect:""}).inputValidator({min:1,onError: "请选择还款方式!"}).defaultPassed();
    $("#type_loan").formValidator({onShow:"至少1个长度",onCorrect:""}).inputValidator({min:1,onError: "请选择收益方式!"}).defaultPassed();
    
    var temp_n = "请输入详细介绍";
    $("#content").formValidator({onShow:temp_n,onfocus:temp_n,onCorrect:input_correct}).inputValidator({min:2,onError:temp_n}).regexValidator({regExp:"notempty",dataType:"enum",onError:temp_n});

    $.formValidator.reloadAutoTip();
});
</script>
<form id="form1" name="form1" onsubmit="chkgeo();" method="post" action="admin.php?ctl=deal&act={{$smarty.request.act}}">
<input type="hidden" name="id" value="{{$smarty.request.id}}">
<input type="hidden" name="actname" value="save">
<input type="hidden" name="type" value="{{if $dealItem.TYPE}}{{$dealItem.TYPE}}{{else}}{{if $smarty.request.t == 'j'}}1{{else}}2{{/if}}{{/if}}">
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="table_list">
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 融资方</td>
    <td class="lf">
        <select name="finance" id="finance">
            <option value=""> - 请选择 - </option>
            {{foreach from=$finance item=item key=key}}
            <option value="{{$key}}"{{if $dealItem.FINANCE == $key}} selected="selected"{{/if}}>{{$item}}</option>
            {{/foreach}}
        </select>            
            <div id="financeTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 贷款用户</td>
    <td class="lf">
            <input name="user_id" type="text" maxlength="20" id="user_id" value="{{$dealItem.USER_ID}}" />
            <div id="user_idTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 借款人</td>
    <td class="lf">
            <input name="deal_person" type="text" maxlength="20" id="deal_person" value="{{$dealItem.DEAL_PERSON}}" />
            <div id="deal_personTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> {{if $dealItem.TYPE == 1 || $smarty.request.t == 'j'}}借款{{else}}理财{{/if}}名称</td>
    <td class="lf">
            <input name="title" type="text" maxlength="20" id="title" value="{{$dealItem.TITLE}}" />
            <div id="titleTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 融资总额</td>
    <td class="lf">
        <input name="price" type="text" maxlength="20" id="price" value="{{$dealItem.PRICE}}" />
        <span class="float_left">（元）</span>
            <div id="priceTip" ></div>
    </td>
    </tr>
    {{if $smarty.request.t == "j" || $dealItem.TYPE == 1}}
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 批准总额</td>
    <td class="lf">
        <input name="price_allow" type="text" maxlength="20" id="price_allow" value="{{$dealItem.PRICE_ALLOW}}" />
        <span class="float_left">（元）</span>
            <div id="price_allowTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"> 批准总额状态</td>
    <td style="text-align:left;">
        <input type="radio" name="state_allow" value="1"{{if $dealItem.STATE_ALLOW == 1 || !$dealItem.ID}} checked="checked"{{/if}} /> 否
        <input type="radio" name="state_allow" value="2"{{if $dealItem.STATE_ALLOW == 2}} checked="checked"{{/if}} /> 是
    </td>
    </tr>
    {{else}}
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 单笔最大投资额</td>
    <td class="lf">
        <input name="max_load" type="text" maxlength="20" id="max_load" value="{{$dealItem.MAX_LOAD}}" />
        <span class="float_left">（元）</span>
            <div id="max_loadTip" ></div>
    </td>
    </tr>
    {{/if}}
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 年化收益率</td>
    <td class="lf">
            <input name="rate" type="text" maxlength="20" id="rate" value="{{$dealItem.RATE}}" />
            <span class="float_left">（%）</span>
            <div id="rateTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 投资期限</td>
    <td class="lf">
        <select name="repay_time" id="repay_time">
            <option value=""> - 请选择 - </option>
            {{foreach from=$repay_time item=item key=key}}
            <option value="{{$key}}"{{if $dealItem.REPAY_TIME == $key}} selected="selected"{{/if}}>{{$item}}</option>
            {{/foreach}}
        </select>
            <div id="repay_timeTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 借款方式</td>
    <td class="lf">
        <select name="type_borrow" id="type_borrow">
            <option value=""> - 请选择 - </option>
            {{foreach from=$type_borrow item=item key=key}}
            <option value="{{$key}}"{{if $dealItem.TYPE_BORROW == $key}} selected="selected"{{/if}}>{{$item}}</option>
            {{/foreach}}
        </select>
            <div id="type_borrowTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 放款方式</td>
    <td class="lf">
        <select name="type_repay" id="type_repay">
            <option value=""> - 请选择 - </option>
            {{foreach from=$type_repay item=item key=key}}
            <option value="{{$key}}"{{if $dealItem.TYPE_REPAY == $key}} selected="selected"{{/if}}>{{$item}}</option>
            {{/foreach}}
        </select>
            <div id="type_repayTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 收益方式</td>
    <td class="lf">
        <select name="type_loan" id="type_loan">
            <option value=""> - 请选择 - </option>
            {{foreach from=$type_loan item=item key=key}}
            <option value="{{$key}}"{{if $dealItem.TYPE_LOAN == $key}} selected="selected"{{/if}}>{{$item}}</option>
            {{/foreach}}
        </select>   
            <div id="type_loanTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 开始还款日期</td>
    <td class="lf">
        <input name="repay_start_time" type="text" maxlength="20" id="repay_start_time" value="{{if $dealItem.REPAY_START_TIME}}{{$dealItem.REPAY_START_TIME|date_format:'%Y-%m-%d'}}{{else}}{{date('Y-m-d')}}{{/if}}" />
            <div id="repay_start_timeTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 流标时间</td>
    <td class="lf">
        <input name="bad_time" type="text" maxlength="20" id="bad_time" value="{{if $dealItem.BAD_TIME}}{{$dealItem.BAD_TIME|date_format:'%Y-%m-%d'}}{{else}}{{date('Y-m-d')}}{{/if}}" />
            <div id="bad_timeTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"><font color="red">*</font> 详细介绍</td>
    <td class="lf">
        <textarea name="content" id="content" rows="5" cols="100" style=" overflow-y: scroll;">{{$dealItem.CONTENT}}</textarea>
            <div id="contentTip" ></div>
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"> 借款状态</td>
    <td style="text-align:left;">
        {{foreach from=$deal_stat item=item key=key}}
        <input type="radio" name="deal_stat" value="{{$key}}"{{if (!$loansItem.ID && $key == 1) || $loansItem.DEAL_STAT == $key}} checked="checked"{{/if}} /> {{$item}}
        {{/foreach}}
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"> 是否前台显示</td>
    <td style="text-align:left;">
        <input type="radio" name="state" value="1"{{if $dealItem.STATE == 1 || !$dealItem.ID}} checked="checked"{{/if}} /> 否
        <input type="radio" name="state" value="2"{{if $dealItem.STATE == 2}} checked="checked"{{/if}} /> 是
    </td>
    </tr>
    <tr class="mouse">
    <td class="lr"> 排序</td>
    <td class="lf">
            <input name="sort_num" type="text" maxlength="20" id="sort_num" value="{{$dealItem.SORT_NUM}}" />
            <div id="sort_numTip" ></div>
    </td>
    </tr>
    <tr class="bottom">
    <td colspan="2" align="center">
        <input type="submit" name="btnSubmit" id="btnSubmit" value="确认保存" />
        &nbsp;&nbsp;
        <input type="button" onclick="javascript:list();" value="返回列表" />
    </td>
    </tr>
</table>
</form>
{{include file="admin/infoot.html"}}
